<!DOCTYPE html>
<link href="<?php echo base_url(); ?>/asset/css/style.css" rel="stylesheet">
<div id="container">
	<h1><?php echo $nama_perusahaan; ?> - FAKTUR PEMBELIAN</h1>
	<h2><?php echo $alamat_perusahaan; ?></h2>

	<div id="body">
		<div id="body">
			<table width="100%" cellpadding="3" cellspacing="0">
            	{kodefktr}
				<tr><td width="110">Kode Faktur</td><td width="20">:</td><td><input type="text" value="{NoFaktur}" class="input-read-only" readonly="true" 
				 style="width:280px;" name="kode_faktur" /></td>
				<tr><td width="110">Tanggal Faktur</td><td>:</td><td>
				<input type="text" value="{DateFaktur}" class="input-read-only" readonly="true" 
				 style="width:280px;" />
				<td colspan="3">&nbsp;</td></tr>
                {/kodefktr}
                {ambilnmsupp}
                <td width="110">Supplier</td><td>:</td><td>
				<input type="text" value="{Suppliername}" class="input-read-only" readonly="true" 
				 style="width:280px;" name="kode_pesanan" /></td></tr>
                 {/ambilnmsupp}
      		</table>
            <br />
			<div class="cleaner_h5"></div>
            
            <table width="100%">
                <thead class="tableCellHeader">
                <th width="15%">Kode Barang</th>
                    <th width="18%">Deskripsi Barang</th>
                    <th width="15%">Qty</th>
                    <th width="10%">Disc %</th>
                    <th width="20%">Total Harga</th>
                <td width="7%"></thead>
                <tbody>        	
                    <?php
                        $i = 0;
                        $totalall = 0;
                        if(count($transfktr) > 0){ 
                            foreach($transfktr as $items){	
                                            
                                $style = "";
                                if($i%2 == 0)$style="cellDefault"; else $style="cellAlternate";
                                echo "<tr class=\"".$style."\">";
                                echo "<td align=\"center\"><input id=\"txtkdbrg[]\" name=\"txtkdbrg[]\" type=\"text\" class=\"flat-textbox-string\" style=\"text-align:center;\" value=\"".$items->KodeDetailBarang."\" readonly=\"readonly\" /></td>";
                                echo "<td align=\"center\"><input id=\"txtprdname[]\" name=\"txtprdname[]\" type=\"text\" class=\"flat-textbox-string\" style=\"text-align:center;\" value=\"".$items->Productname."\" readonly=\"readonly\" /></td>";
                                echo "<td style=\"text-align:center;\"><input id=\"txtqty[]\" name=\"txtqty[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:right;\" value=\"".$items->Quantity."\" readonly=\"readonly\" />&nbsp;".$items->Typeunit."</td>";
                                $disc = isset($items->options['Discount'])?$items->options['Discount'] : 0;						
                                echo "<td align=\"center\"><input id=\"txtdisc[]\" name=\"txtdisc[]\" type=\"text\" class=\"flat-textbox-string\" style=\"text-align:center;\" value=\"".$disc."\" readonly=\"readonly\" /></td>";
                                $qty = 0;
                                $harga = 0;
                                $qty = intval($items->Quantity);
                                //$harga = intval($items->HargaBarang);
                                $total = 0;
                                
                                if(intval($disc) != 0){
                                    //$total = ($qty * $harga) - ((intval($disc) * ($qty * $harga))/100);
                                    $total = $items->Amount;
                                    $totalall = $totalall + $total;
                                }else{
                                    //$total = $qty * $harga;
                                    $total = $items->Amount;
                                    $totalall = $totalall + $total;
                                }
                                echo "<td style=\"text-align:right;\"><input id=\"txtTotal[]\" name=\"txtTotal[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:right;\" value=\"".$total."\" readonly=\"readonly\" /></td>";
                                echo "<input type=\"hidden\" id=\"ttlamount[]\" name=\"ttlamount[]\" value=\"".$total."\" />";
                                echo "</tr>";
                                $i++;				
                            }
                        }else{
                            echo "<tr><td colspan=\"6\" style=\"text-align:center;color:red;\">No Data To Display</td></tr>";
                        }
                    ?>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="4" style="text-align:right;font-weight:bold;font-size:12pt;" class="flat-textbox-string">Subtotal</td>
                        <td style="text-align:right;font-size:1em;font-weight:bold;border:1px solid black;" class="flat-textbox-number"><?php echo $totalall?></td>
                    </tr>
                </tfoot>
            </table>
            
            
			<!--<table border="1" cellpadding="4" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record">
			<tr style="background-color:#333; color:#FFFFFF;" align="center">
				<td>Kode Barang</td>
				<td>Deskripsi Barang</td>
				<td>Qty</td>
				<td>Discount</td>
                <td>Jumlah</td>
			</tr>
            {transfktr}
            <tr class="cellDefault">
                <td align="center">{KodeDetailBarang}</td>
                <td align="center">{Productname}</td>
                <td align="left">{Quantity}</td>
                <td align="center">{Discount}</td>
                <td align="center">{Amount}</td>
                <?php 
				$ttlamt = $ttlamt + $ttlamt;
				
				?>
            </tr>
        	{/transfktr}
			<tr>
				<td colspan="6">Sub Total</td>
				<td>Rp. <?php echo $this->cart->format_number($total); ?><input type="hidden" value="<?php echo $total; ?>" name="total" /></td>
			</tr>
			<tr>
				<td colspan="6">Discount</td>
				<td>Rp. <?php echo number_format($bayar,2,'.',','); ?></td>
			</tr>
			<tr>
				<td colspan="6">Ppn</td>
				<td>Rp. <?php echo number_format($sisa_bayar,2,'.',','); ?></td>
			</tr>
            <tr>
				<td colspan="6">Total</td>
				<td>Rp. <?php echo number_format($sisa_bayar,2,'.',','); ?></td>
			</tr>
			</table>-->
			<div class="cleaner_h10"></div>
	  </div>
	</div>